home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWIntl / Include / FWIntStr.h < prev   
Encoding:
Text File  |  1995-11-08  |  3.3 KB  |  134 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWIntStr.h
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWINTSTR_H
  11. #define FWINTSTR_H
  12.  
  13.  
  14. // --- International Includes ---
  15.  
  16. #ifndef FWITEXT_H
  17. #include "FWIText.h"
  18. #endif
  19.  
  20. // --- Foundation includes ---
  21.  
  22. #ifndef FWSTDDEF_H
  23. #include "FWStdDef.h"
  24. #endif
  25.  
  26. #ifndef FWCHARAC_H
  27. #include "FWCharac.h"
  28. #endif
  29.  
  30. #ifndef FWSTRS_H
  31. #include "FWStrs.h"
  32. #endif
  33.  
  34. // --- OpenDoc includes ---
  35.  
  36. #ifndef _ODTYPES_
  37. #include <ODTypes.h>
  38. #endif
  39.  
  40. // --- Platform includes ---
  41.  
  42. #ifdef FW_BUILD_MAC
  43. #include <Types.h>
  44. #endif
  45.  
  46. #if FW_LIB_EXPORT_PRAGMAS
  47. #pragma lib_export on
  48. #endif
  49.  
  50. //========================================================================================
  51. //    CLASS FW_CIntlString - a dynamic string that holds script and language information
  52. //========================================================================================
  53.  
  54. class FW_CLASS_ATTR FW_CIntlString : public FW_CString
  55. {
  56.   public:
  57.  
  58.     FW_DECLARE_CLASS
  59.     
  60.     enum {kDefaultCapacity = 255};
  61.  
  62.     ~FW_CIntlString();
  63.  
  64.     FW_CIntlString(ODScriptCode scriptCode=FW_kDefaultScriptCode, ODLangCode langCode=FW_kDefaultLangCode);
  65.         // default constructor
  66.  
  67.     FW_CIntlString(ODIText* iText);
  68.  
  69.     FW_CIntlString(const FW_CIntlString& string);
  70.         // copy constructor
  71.  
  72.     FW_CIntlString(const FW_CString& string,
  73.                    ODScriptCode scriptCode=FW_kDefaultScriptCode, ODLangCode langCode=FW_kDefaultLangCode);
  74.         // copy constructor
  75.  
  76.     FW_CIntlString(const FW_Char *chars, FW_CharacterCount numberChars, 
  77.                    ODScriptCode scriptCode=FW_kDefaultScriptCode, 
  78.                    ODLangCode langCode=FW_kDefaultLangCode);
  79.  
  80.     FW_CIntlString(const FW_Char *chars, 
  81.                    ODScriptCode scriptCode=FW_kDefaultScriptCode, 
  82.                    ODLangCode langCode=FW_kDefaultLangCode);
  83.  
  84.     FW_CIntlString& operator=(const FW_CIntlString& string);
  85.     FW_CIntlString& operator=(const FW_CString& string);
  86.  
  87.     virtual FW_ByteCount GrowCapacity(FW_ByteCount capacityNeeded);    // Override
  88.  
  89.     ODLangCode GetLangCode() const;
  90.     ODScriptCode GetScriptCode() const;
  91.  
  92.     ODIText* CreateIText() const;
  93.         // Allocate an ODIText and initialize its fields from this string.
  94.  
  95.   protected:
  96.     void AdjustCharWidth();
  97.     virtual FW_CharacterCount CalcLength();
  98.  
  99.   private:
  100.     void AllocateRepresentation(FW_ByteCount capacity=kDefaultCapacity);
  101.  
  102.     ODScriptCode    fScriptCode;
  103.     ODLangCode        fLanguageCode;
  104. };
  105.  
  106. //========================================================================================
  107. // FW_CIntlString inlines
  108. //========================================================================================
  109.  
  110. //----------------------------------------------------------------------------------------
  111. inline void FW_CIntlString::AllocateRepresentation(FW_ByteCount capacity)
  112. {
  113.     fRepresentation = new FW_Byte[capacity+FW_kMedianCharacterSize];
  114.     fCapacity = capacity;
  115. }
  116.  
  117. //----------------------------------------------------------------------------------------
  118. inline ODScriptCode FW_CIntlString::GetScriptCode() const
  119. {
  120.     return fScriptCode;
  121. }
  122.  
  123. //----------------------------------------------------------------------------------------
  124. inline ODLangCode FW_CIntlString::GetLangCode() const
  125. {
  126.     return fLanguageCode;
  127. }
  128.  
  129. #if FW_LIB_EXPORT_PRAGMAS
  130. #pragma lib_export off
  131. #endif
  132.  
  133. #endif
  134.